package com.wy.timer.impl2;

import java.util.concurrent.PriorityBlockingQueue;

/**
 * @author 美女
 * @date 2022/05/03 10:46
 **/
public class MyTimer {
    private final PriorityBlockingQueue<MyTimerTask> queue=new PriorityBlockingQueue<>();

    public MyTimer() {
        Worker worker=new Worker(queue);
        worker.start();
    }
    public void schedule(MyTimerTask task,long delay){
        task.runAt=System.currentTimeMillis()+delay;
        queue.put(task);
    }
}
